// There's no way to disable or enable a pull mirror, so if the boolean
// isn't set, then we don't have a pull mirror.
- return unless @project.mirror?

- import_state = @project.import_state

- return unless import_state

%tr{ data: { qa_selector: 'mirrored_repository_row_container' } }
  %td.mirror-url{ data: { qa_selector: 'mirror_repository_url_content' } }
    = @project.safe_import_url
    = render_if_exists 'projects/mirrors/mirror_branches_setting_badge', record: @project
  %td= _('Pull')
  %td
    = import_state.last_update_started_at.present? ? time_ago_with_tooltip(import_state.last_update_started_at) : _('Never')
  %td{ data: { qa_selector: 'mirror_last_update_at_content' } }= import_state.last_successful_update_at.present? ? time_ago_with_tooltip(import_state.last_successful_update_at) : _('Never')
  %td
    - if import_state&.last_error.present?
      = gl_badge_tag _('Error'), { variant: :danger }, { data: { toggle: 'tooltip', html: 'true' }, title: html_escape(import_state.last_error.try(:strip)) }
  %td.mirror-action-buttons
    .btn-group.mirror-actions-group{ role: 'group' }
      - ssh_public_key = @project.import_data.ssh_public_key
      - if ssh_public_key
        = clipboard_button(text: ssh_public_key, class: 'gl-button btn btn-default btn-icon rspec-copy-ssh-public-key', title: _('Copy SSH public key'), qa_selector: 'copy_public_key_button')
      - if import_state.mirror_update_due? || import_state.updating_mirror?
        = render Pajamas::ButtonComponent.new(icon: 'retry',
          button_options: { class: 'disabled', title: _('Updating'), data: { container: 'body', toggle: 'tooltip', testid: 'updating-button' } },
          icon_classes: 'spin')
      - elsif @project.archived?
        = render Pajamas::ButtonComponent.new(icon: 'retry',
          button_options: { class: 'disabled', title: _('This Project is currently archived and read-only. Please unarchive the project first if you want to resume Pull mirroring'), data: { container: 'body', toggle: 'tooltip', qa_selector: 'update_now_button', testid: 'update-now-button' } },
          icon_classes: 'spin')
      - else
        = link_to update_now_project_mirror_path(@project), method: :post, class: 'btn gl-button btn-icon btn-default js-force-update-mirror', data: { container: 'body', toggle: 'tooltip', qa_selector: 'update_now_button', testid: 'update-now-button' }, title: _('Update now') do
          = sprite_icon("retry")
      = render Pajamas::ButtonComponent.new(variant: :danger,
        icon: 'remove',
        button_options: { class: 'js-delete-mirror js-delete-pull-mirror', title: _('Remove'), data: { toggle: 'tooltip', container: 'body' } })
